<?php
include ("boot.php");

//$oADODB->debug = true;
// ==========================================================================
// User Class
// ==========================================================================

$oLink = new daoLinks($oADODB);
$oLink->clean();
$oRelation = new daoRelLinks($oADODB);
$oRelation->clean();

// removes slashes
$sViewdb = stripslashes($_GET['viewdb']);

// decode json recieved from Bindows to Array
$aRequest = json_decode($sViewdb, true);

// link
$aRequestRel['vLnkName'] = $aRequest['vLnkNameLink'];
$aRequestRel['vURL'] = str_replace("http://", "", $aRequest['vURL']);
$aRequestRel['iUseID'] = $_SESSION['iUseID'];
$oLink->save($aRequestRel);

// relation
$aRequestSave['iRelChildID'] = $oLink->iLastID;
$aRequestSave['iRelParentID'] = $aRequest['iRelParentIDLink'];
$oRelation->save($aRequestSave);

// return menu
$o = new Menu;
$oResponse->oMenu = $o->getMenu();

// print response
echo json_encode($oResponse);
?>